<?php
/**
 * Panxsoft Api 控制器父类
 * 可以使用 checker 与 responser
 *
 *
 * @author Zeon scplay@gmail.com
 * @date 2017/11/9
 * @copyright Created by Panxsoft.
 */
namespace App\Http\Controllers;

use App\Models\Admin\CustomerAdmin;
use App\Services\Utils\ApiChecker;
use App\Services\Utils\ApiResponser;
use App\Services\Utils\Guard;
use Illuminate\Routing\Controller as BaseController;

abstract class ApiController extends Controller
{
    use ApiChecker,
        ApiResponser;

    /**
     * 检测customer是否合法
     *
     * @throws \Exception
     */
    public function checkCustomer()
    {
        $customer = Guard::customer();
        $this->checkIsTrue(!$customer->isProviderTypeVirtualProvider(), trans('admin.is_virtual_provider'));

        // 超管才能操作的
        $this->checkIsTrue(CustomerAdmin::isGuardSuperAdmin(), trans('admin.is_super_man'));
    }
}
